package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:张熳
 * Date:2025-08-24
 * Time:17:47
 */
//多态
//向上转型和 向下转型(instanceof) + 重写

public class Animal {
    public String name;
    public int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void eat(){
        System.out.println(this.name + " 正在吃饭...");
    }
    //返回值类型可以不一样，但是必须构成父子关系
    public Animal sleep(){
        System.out.println(this.name + " 睡觉~");
        return null;
    }
}
